package cn.fay.chapter14;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public class BaseTypesDemo1 {
	public static final List allTypes=
			Collections.unmodifiableList(Arrays.asList(byte.class,short.class,int.class,long.class,
												char.class,float.class,double.class,boolean.class));
	public static  Class createType(){
		Random random=new Random();
		return (Class) allTypes.get(random.nextInt(allTypes.size()));
	}
	public static  ArrayList<Class> createType(int size){
		Random random=new Random();
		ArrayList<Class> list=new ArrayList<Class>();
		for (int i = 0; i <size; i++) {
			list.add((Class) allTypes.get(random.nextInt(allTypes.size())));
		}
		return list;
	}
	public static void main(String[] args) {
		ArrayList<Class> types = BaseTypesDemo1.createType(20);
		System.out.println(types);
	}
}
